package winter_vacation_homework.day_15;

import java.util.HashMap;
import java.util.Map;

/**
 * 【牛客题号: NC31 第一个只出现一次的字符】
 * https://www.nowcoder.com/practice/1c82e8cf713b4bbeb2a5b31cf5b0417c?tpId=188&&tqId=38575&rp=1&ru=/activity/oj&qru=/ta/job-code-high-week/question-ranking
 */
public class FirstCharacterOccursOnlyOnce {
    public int FirstNotRepeatingChar(String str) {
        String[] strArray = str.split("");
        int count = 0;
        for (int i = 0; i < strArray.length; i++) {
            for (int j = 0; j < strArray.length; j++) {
                if (strArray[i].equals(strArray[j])) {
                    count++;
                }
            }
            if (count == 1) {
                return i;
            } else {
                count = 0;
            }

        }
        return -1;
    }
}
